package com.kitchen.ui.controls
{
	import flash.display.Loader;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.MouseEvent;
	import flash.events.ProgressEvent;
	import flash.net.URLRequest;

	public class Portrait extends Sprite
	{
		public static const E_INFO:String = 'pinfo';
		
		private var loader:Loader;
		
		public function Portrait(photo:String, w:int =30, h:int = 30)
		{
			super();
			loader = new Loader();
			loader.load(new URLRequest(photo));
			loader.contentLoaderInfo.addEventListener(Event.OPEN, onOpen);
			loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProcess);
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
			loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
			this.addChild(loader);
			var shape:Shape = new Shape();
			shape.graphics.beginFill(0xffffff, 1);
			shape.graphics.drawRoundRect(0, 0, w, h, 10, 10);
			shape.graphics.endFill();
			this.mask = shape;
			this.addChild(shape);
			this.useHandCursor = true;
			this.buttonMode = true;
		}
		
		private function onComplete(e:Event):void{
			this.loader.removeEventListener(Event.OPEN, onOpen);
			this.loader.removeEventListener(ProgressEvent.PROGRESS, onProcess);
			this.loader.removeEventListener(Event.COMPLETE, onComplete);
			this.loader.removeEventListener(IOErrorEvent.IO_ERROR, onError);
		}
		
		private function onOpen(e:Event):void{
			
		}
		
		private function onProcess(pe:ProgressEvent):void{
			
		}
		
		private function onError(ioe:IOErrorEvent):void{
			
		}
		
	}
}